import com.yu.annotation.RpcScanner;
import com.yu.service.RpcServiceProperties;
import com.yu.HelloServiceImpl2;
import com.yu.transport.server.NettyServer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @PackageName: com.yu
 * @Description:
 * @Version: v1.0.0
 * @Author: yuweilin
 * @Date: 14:34
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2021/1/21      yuweilin         v1.0.0               新建
 */
@RpcScanner(basePackage ={"com.yu"})
public class RpcServer {
    public static void main(String[] args) throws InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RpcServer.class);
        String[] names = context.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }
        NettyServer server = (NettyServer) context.getBean("nettyServer");
        HelloServiceImpl2 impl2 = new HelloServiceImpl2();
        RpcServiceProperties rpcServiceProperties = RpcServiceProperties.builder().version("version2").group("test2").build();
        server.registerService(impl2,rpcServiceProperties);
        server.start();

    }
}
